home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJINC106.ARJ / STDIO.H < prev    next >
C/C++ Source or Header  |  1992-03-09  |  8KB  |  316 lines

  1. /* This is file stdio.h */
  2. /* This file may have been modified by DJ Delorie (Jan 1991).  If so,
  3. ** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave,
  4. ** Rochester NH, 03867-2954, USA.
  5. */
  6.  
  7. /* This may look like C code, but it is really -*- C++ -*- */
  8. /* 
  9. Copyright (C) 1988 Free Software Foundation
  10.     written by Doug Lea (dl@rocky.oswego.edu)
  11.  
  12. This file is part of GNU CC.
  13.  
  14. GNU CC is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY.  No author or distributor
  16. accepts responsibility to anyone for the consequences of using it
  17. or for whether it serves any particular purpose or works at all,
  18. unless he says so in writing.  Refer to the GNU CC General Public
  19. License for full details.
  20.  
  21. Everyone is granted permission to copy, modify and redistribute
  22. GNU CC, but only under the conditions described in the
  23. GNU CC General Public License.   A copy of this license is
  24. supposed to have been given to you along with GNU CC so you
  25. can know your rights and responsibilities.  It should be in a
  26. file named COPYING.  Among other things, the copyright notice
  27. and this notice must be preserved on all copies.  
  28. */
  29.  
  30. /*
  31.  *  Please check the following before installing this file:
  32.  *
  33.  *  Make sure USG is #defined if you are on a USG system!
  34.  *
  35.  *  Check the value of _NFILE against the one in your /usr/include/stdio.h.
  36.  *  (USG only)
  37.  *
  38.  *  Check whether your libc.a sprintf function returns
  39.  *  an int (as do most) versus a char* (BSD), and (un)comment
  40.  *  the corresponding SPRINTF_RETURNS_INT line.
  41.  *
  42.  *  Check the value of BUFSIZ against the one in your /usr/include/stdio.h.
  43.  *
  44.  *  Carefully check the fields and order of _iobuf declaration against
  45.  *  the one in your /usr/include/stdio.h. Xenix-based systems
  46.  *  may need some re-ordering of _iobuf. fields.
  47.  *
  48.  *  Note that some _IOXXX #defines may not be present in your 
  49.  *  /usr/include/stdio.h. This is ok, so long as the ones that
  50.  *  are present in both are set to the same values.
  51.  *
  52.  *  Some of the prototypes refer to functions that may not be
  53.  *  present in your libc.a. This is ok so long as you do not
  54.  *  actually call such functions.
  55.  *
  56.  */
  57.  
  58. #ifndef _stdio_h_
  59. #define _stdio_h_
  60.  
  61.  
  62. /*
  63.    HAVE_VPRINTF should be set if vprintf is in libc.a
  64.    HAVE_SETVBUF should be set if setvbuf is in libc.a
  65.    HAVE_SETLINEBUF should be set if setlinebuf in libc.a
  66.  
  67.    The following are probably correct for the listed systems
  68.  
  69. */
  70.  
  71. #define STDC_HEADERS
  72.  
  73. #ifdef SYSTEM_FIVE
  74. #define USG
  75. #endif
  76.  
  77. #if defined(USG)
  78. #define  HAVE_VPRINTF
  79. #define  HAVE_SETVBUF  
  80. /* #define  HAVE_SETLINEBUF */
  81.  
  82. #elif defined(vax) || defined(sony)
  83. /* #define HAVE_VPRINTF */
  84. /* #define  HAVE_SETVBUF  */
  85. #define HAVE_SETLINEBUF
  86.  
  87. #elif defined(sun)
  88. #define  HAVE_VPRINTF
  89. #define  HAVE_SETVBUF  
  90. #define  HAVE_SETLINEBUF
  91.  
  92. #elif defined(sequent)
  93. /* #define  HAVE_VPRINTF */
  94. /* #define  HAVE_SETVBUF */
  95. #define  HAVE_SETLINEBUF
  96.  
  97. #elif defined(DGUX)
  98. #define HAVE_VPRINTF
  99. #define HAVE_SETVBUF
  100. #define HAVE_SETLINEBUF
  101. #define IOBUF_FLAG_TYPE int
  102. #define IOBUF_FILE_TYPE int
  103. #define _NFILE 64
  104. #define IOBUF_EXTRA_FIELDS      int _reserve[27];
  105. #define SPRINTF_RETURNS_INT
  106. #define BUFEND_ENTRY_TYPE unsigned char *
  107. #define USG
  108.  
  109. #elif defined(TEKTRONIX_SYSV) || defined(hp9000s300) || defined(i386)
  110. #define  HAVE_VPRINTF
  111. #define  HAVE_SETVBUF
  112. #define HAVE_SETLINEBUF
  113. #define  USG
  114. #undef USG /*DJ*/
  115.  
  116. #elif defined(convex)
  117. /* #define HAVE_VPRINTF */
  118. /* #define HAVE_SETVBUF */
  119. #define HAVE_SETLINEBUF
  120. #define IOBUF_FILE_TYPE unsigned char
  121. #define HAVE_VOID_DOPRNT
  122.  
  123. #endif
  124.  
  125. #ifdef hpux
  126. #define IOBUF_FLAG_TYPE char
  127. #endif
  128.  
  129. #ifdef USG
  130. #define IOBUF_BUFSIZ_FIELD      /* System V ain't got one */
  131. #endif
  132.  
  133. /* Some default definitions for things not defined machine-specifically
  134.    above.  */
  135.  
  136. #ifndef IOBUF_BUFSIZ_FIELD
  137. #define IOBUF_BUFSIZ_FIELD int _bufsiz;
  138. #endif
  139.  
  140. #ifndef IOBUF_FLAG_TYPE
  141. #define IOBUF_FLAG_TYPE short
  142. #endif
  143.  
  144. #ifndef IOBUF_FILE_TYPE
  145. #define IOBUF_FILE_TYPE char
  146. #endif
  147.  
  148. #ifndef IOBUF_EXTRA_FIELDS
  149. #define IOBUF_EXTRA_FIELDS
  150. #endif
  151.  
  152. #if defined(USG) && !defined(_NFILE)
  153. #define _NFILE 20
  154. #endif
  155.  
  156. #ifdef USG
  157. #define _bufend(p) _bufendtab[(p)->_file]
  158. #define _bufsiz(p) (_bufend(p) - (p)->_base)
  159. #ifndef BUFEND_ENTRY_TYPE
  160. #define BUFEND_ENTRY_TYPE char *
  161. #endif
  162. #ifdef __cplusplus
  163. extern "C" {
  164. #endif
  165. BUFEND_ENTRY_TYPE _bufendtab[];
  166. #ifdef __cplusplus
  167. }
  168. #endif
  169. #endif
  170.  
  171. /* check this -- hardly any systems need this these days */
  172. #define SPRINTF_RETURNS_INT
  173.  
  174. /* check and possibly redefine the following */
  175. #define BUFSIZ  4096
  176.  
  177. extern  struct  _iobuf {
  178.     int      _cnt;
  179.     char*    _ptr;
  180.     char*    _base;
  181.     IOBUF_BUFSIZ_FIELD
  182.     IOBUF_FLAG_TYPE     _flag;
  183.     IOBUF_FILE_TYPE     _file;
  184.     IOBUF_EXTRA_FIELDS
  185. } _iob[];
  186.  
  187. typedef struct _iobuf FILE;
  188.  
  189. #define _IOFBF    00000
  190. #define _IOREAD   00001
  191. #define _IOWRT    00002
  192. #define _IONBF    00004
  193. #define _IOMYBUF  00010
  194. #define _IOEOF    00020
  195. #define _IOERR    00040
  196. #if defined(USG) && !defined(hpux)
  197. #define _IOSTRG   00000  /* faked out for USG */
  198. #define _IOLBF    00100
  199. #define _IORW     00200
  200. #define _IOAPPEND 00000 /* faked out for USG */
  201. #elif defined(hpux)
  202. #define _IOSTRG   00000  /* faked out for USG */
  203. #define _IOLBF    00200
  204. #define _IORW     00400
  205. #define _IOAPPEND 00000 /* faked out for USG */
  206. #else
  207. #define _IOSTRG   00100
  208. #define _IOLBF    00200
  209. #define _IORW     00400
  210. #define _IOAPPEND 01000
  211. #endif
  212. #ifdef DGUX
  213. #define _IOPBF    00400  /* Boolean - ungetc() not called since fill/flush */
  214. #endif
  215. #define _IOTEXT   02000  /* for MSDOS cr/lf style files */
  216.  
  217. #define EOF       (-1)
  218.  
  219. #ifndef NULL
  220. #define NULL      0
  221. #endif
  222.  
  223. #define stdin     (&_iob[0])
  224. #define stdout    (&_iob[1])
  225. #define stderr    (&_iob[2])
  226. #define stdaux    (&_iob[3])
  227. #define stdprn    (&_iob[4])
  228.  
  229. #define getc(p) (--(p)->_cnt>=0 ? \
  230.   (int)(*(unsigned char*)(p)->_ptr++) : \
  231.   _filbuf(p))
  232. #define putc(x,p) (--(p)->_cnt>=0? \
  233.   ((int)((unsigned char)((*(p)->_ptr++=(unsigned)(x))))): \
  234.   _flsbuf((unsigned)(x),p))
  235.  
  236. #define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))
  237. #define getchar()   getc(stdin)
  238. #define putchar(x)  putc(x,stdout)
  239. #define feof(p)     (((p)->_flag&_IOEOF)!=0)
  240. #define ferror(p)   (((p)->_flag&_IOERR)!=0)
  241. #define fileno(p)   ((p)->_file)
  242.  
  243. #ifdef __cplusplus
  244. extern "C" {
  245. #endif
  246.  
  247. int    _doprnt(const char*, void *, FILE*);
  248. int    _doscan(FILE*, const char*, void **argp);
  249. int    _filbuf(FILE*);
  250. int    _flsbuf(unsigned, FILE*);
  251. int    fclose(FILE*);
  252. FILE*  fdopen(int, const char*);
  253. int    fflush(FILE*);
  254. int    fgetc(FILE*);
  255. char*  fgets(char*, int, FILE *);
  256. FILE*  fopen(const char*, const char*);
  257. int    fprintf(FILE*, const char*, ...);
  258. int    fputc(int, FILE*);
  259. int    fputs(const char*, FILE*);
  260. int    fread(void*, int, int, FILE*);
  261. FILE*  freopen(const char*, const char*, FILE*);
  262. int    fscanf(FILE*, const char*, ...);
  263. int    fseek(FILE*, long, int);
  264. long   ftell(FILE *);
  265. int    fwrite(const void*, int, int, FILE*);
  266. char*  gets(char*);
  267. int    getw(FILE*);
  268. int    pclose(FILE*);
  269. FILE*  popen(const char*, const char*);
  270. int    printf(const char*, ...);
  271. int    puts(const char*);
  272. int    putw(int, FILE*);
  273. int    rewind(FILE*);
  274. int    scanf(const char*, ...);
  275. int    setbuf(FILE*, char*);
  276. int    setbuffer(FILE*, char*, int);
  277. int    setlinebuf(FILE*);
  278. int    setvbuf(FILE*, char*, int, int);
  279. int    sscanf(char*, const char*, ...);
  280. FILE*  tmpfile();
  281. int    ungetc(int, FILE*);
  282. int    vfprintf(FILE*, const char*, ...);
  283.  
  284. /* Third arg to vprintf must be '...' for some machines, & does not */
  285. /* hurt for others. */
  286.  
  287. int    vprintf(const char*, ... );
  288.  
  289. #ifdef SPRINTF_RETURNS_INT
  290. int    sprintf(char*, const char*, ...);
  291. int    vsprintf(char*, const char*, ...);
  292. #else
  293. char*  sprintf(char*, const char*, ...);
  294. char*  vsprintf(char*, const char*, ...);
  295. #endif
  296.  
  297. #ifdef __cplusplus
  298. }
  299. #endif
  300.  
  301. #ifndef L_ctermid
  302. #define L_ctermid       9 
  303. #endif
  304. #ifndef L_cuserid
  305. #define L_cuserid       9
  306. #endif
  307. #ifndef P_tmpdir
  308. #define P_tmpdir    "/tmp/"
  309. #endif
  310. #ifndef L_tmpnam
  311. #define L_tmpnam    (sizeof(P_tmpdir) + 15)
  312. #endif
  313.  
  314.  
  315. #endif /* _stdio_h_ */
  316.